package com.zfast.spring5.Integration;

import com.zfast.spring5.model.User;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.handler.GenericHandler;
import org.springframework.messaging.MessageHeaders;
import org.springframework.stereotype.Component;

import java.util.Arrays;

/**
 * 处理单元（发送消息）
 * @author zgn
 * @Description: RegisterRabbitMQSendHandler
 * @date 2022/3/19
 */
@Component
public class RegisterRabbitMQSendHandler implements GenericHandler<User> {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    @Override
    public Object handle(User user, MessageHeaders messageHeaders) {
        //rabbitTemplate.convertAndSend(user);
        rabbitTemplate.convertSendAndReceive("zgn.direct","user.news",
                Arrays.asList("好像还不错哦",123,true));
        return null;
    }
}